﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MixScriptWeb.control;
using MixScriptWeb.Share;
using MixScript.BLL;
using MixScriptWeb.AppCode.gjips;
using MixScript.BLL.WM;


namespace MixScriptWeb.Jideco.WM
{
    public partial class MOFInq : cCommonWeb // System.Web.UI.Page
    {
        private static DataTable dt;
        private static DataTable dtprint;
        private static SortDirection sd;
        private static cRefGjips oReff;
        private const string stblname = "vw_mofrpt";
        private static string scustid, potyp = "";


        protected void Page_Load(object sender, EventArgs e)
        {
               try
            {
                if (!Page.IsPostBack)
                {
                   // addFindClickAttribute(this, new MixScriptTB[] { txtSupCode }, new string[] { "SRCSUPGJ" });              
                    txtDate1.CssClass += " ritonli";
                    string[] sheadertext = new string[] { "Date", "MOF No", "Section" };
                    string[] sdatavalue = new string[] { "dtcreated", "mofno", "section"};              
                    initGvColumn(gvdetail, sheadertext, sdatavalue, new int[] { 0}, "{0:dd-MM-yyyy}");
                    txtDate1.Text = DateTime.Now.ToString("dd-MM-yyyy");
                    txtDate2.Text = DateTime.Now.ToString("dd-MM-yyyy");
                }
                mn = (MainMenu)this.Master;
                hideStatusBar();                
            }
            catch (Exception)
            {
                
                throw;
            }

        }

        protected void btnFind_Click(object sender, EventArgs e)
        {
            try
            {
                //oReff = new cRefGjips(); //new cUserManagement();
                dt = new DataTable();
                //Control[] ctl = new Control[] { txtPONum, txtSupCode, null, null, txtDate1 };
                cMOF oPo = new cMOF();
                DateTime tgl1 = new DateTime();
                DateTime tgl2 = new DateTime();

                if(txtDate1.Text!=string.Empty)
                    tgl1=DateTime.Parse(toMDY(txtDate1.Text));

                
                if(txtDate2.Text!=string.Empty)
                    tgl2=DateTime.Parse(toMDY(txtDate2.Text));

                                                
                if (oPo.getmoflist(ref dt, txtPONum.Text, tgl1, tgl2, stblname))
                {
                   
                    
                }
                else
                {
                    ShowStatusBar("Record Not Found", msgType.msgError);
                }
                bindGridview(gvdetail, dt);


            }
            catch (Exception)
            {

                throw;
            }
        }

        protected void btnClear_Click(object sender, EventArgs e)
        {

        }

        protected void gvdetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void gvdetail_Sorting(object sender, GridViewSortEventArgs e)
        {

        }

        protected void gvdetail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
                    string sid = e.Row.Cells[2].Text.Replace("-","@");
                    lb.OnClientClick = "printdn('../print/rptid-12,mofno-" + sid.Replace("/","qwerty") + ",dl.html')";
                    //lb.OnClientClick = "printdn('../print/rptid-2,spono-JJ1206009,suppid-0001%20%20%20%20%20%20,dl.html')";
                }


            }
            catch (Exception ex)
            {

                ShowStatusBar(ex.Message);
            }
        }
    }
}